<?php
require_once "config.php";

$username = $_POST['username'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
if($password1 == $password2){
    $sql = "insert into admin(name,password) value('{$username}','{$password1}')";
    $rst = mysqli_query($con,$sql);
    $id = mysqli_insert_id($con);
    if($id){
        echo "<script>alert('插入成功!');window.location.href='main_list.php';</script>";
    }else{
        echo "<script>alert('插入失败,请重新输入');window.location.href='user_add.php';</script>";
    }
}else{
    echo "<script>alert('两次密码不一致,请重新输入');window.location.href='user_add.php';</script>";
}